﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Web;

namespace Macaw.Wss3.DependencySpiderSolution.FeatureCode
{
    public class DependencyQuickAccessButton : ConsoleAction
    {
        public override Microsoft.SharePoint.SPBasePermissions UserRights
        {
            get 
            {
                return SPBasePermissions.EmptyMask;
            }
        }

        public override string NavigateUrl
        {
            get
            {
                if (SPContext.Current == null || SPContext.Current.Web == null || SPContext.Current.ListItem == null || SPContext.Current.ListItem.File == null) return null;
                return string.Format("javascript: window.open('{0}');" , SPUrlUtility.CombineUrl( SPContext.Current.Web.ServerRelativeUrl ,"/_layouts/Macaw.Wss3.DependencySpiderSolution/PageDependencies.aspx?ItemUrl=" + HttpUtility.UrlEncode( SPContext.Current.ListItem.File.ServerRelativeUrl) ) );
            }
            set
            {
                base.NavigateUrl = value;
            }
        }

    }
}
